﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using System.Text.RegularExpressions;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;

using System.Globalization;

namespace BlogEngine.NET.MVC.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {

            IList<IPublishable> p = GetVisiblePosts();

            return View(p);
        }

        public ActionResult About()
        {
            return View();
        }

        public List<IPublishable> GetVisiblePosts()
        {
            Posts = Post.Posts.ConvertAll( new Converter<Post, IPublishable>( delegate( Post p ) { return p as IPublishable; } ) );

            return Posts.FindAll( delegate( IPublishable p ) { return p.IsVisible; } );
        }

        #region Properties

        private List<IPublishable> _Posts;
        /// <summary>
        /// The list of posts to display.
        /// </summary>
        public List<IPublishable> Posts
        {
            get { return _Posts; }
            set { _Posts = value; }
        }

        #endregion
    }
}
